package cn.bxshey.resourceSharing.service.impl;

import cn.bxshey.resourceSharing.entity.Faqs;
import cn.bxshey.resourceSharing.mapper.FaqsMapper;
import cn.bxshey.resourceSharing.service.FaqsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (Faqs)表服务实现类
 *
 * @author makejava
 * @since 2023-12-18 08:50:33
 */
@Service
public class FaqsServiceImpl extends ServiceImpl<FaqsMapper, Faqs> implements FaqsService {


    @Resource
    FaqsMapper faqsMapper;

    /**
     * 分页查询所有数据
     *
     * @param current
     * @param size
     * @param issue
     */
    @Override
    public Map<String,Object> page(Integer current, Integer size, String issue) {
        Map<String,Object> map = new HashMap<>();
        map.put("records",faqsMapper.page((current-1)*size,size,issue)); //数据
        Long count = faqsMapper.count(issue);
        map.put("count",count); //总数
        map.put("page",count%size==0 ? count/size : (count/size)+1); //总页数
        return map;
    }
}

